<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    {:token()}
    <input type="hidden" name="row[salt]" id="c-salt" value="<?php echo $salt = \fast\Random::alnum();?>">
    <input type="hidden" name="row[passwordtext]" id="c-passwordtext" value="">
    <input type="hidden" name="row[status]" id="c-status" value="normal">
    <div class="form-group">
        <label for="c-username" class="control-label col-xs-12 col-sm-2">{:__('Username')}:</label>
        <div class="col-xs-12 col-sm-4">
            <input id="c-username" data-rule="required" class="form-control" name="row[username]" type="text" value=""
                placeholder="{:__('用户名必须3-30个字符')}">
        </div>
    </div>
    <div class="form-group">
        <label for="c-password" class="control-label col-xs-12 col-sm-2">{:__('Password')}:</label>
        <div class="col-xs-12 col-sm-4">
            <input id="c-password" data-rule="required" class="form-control" name="row[password]" type="text" value=""
                readonly="readonly" placeholder="{:__('密码点击重置随机生成')}" autocomplete="new-password" />
        </div>
        <div class="col-xs-12 col-sm-4">
            <button type="button" onclick="resetpassword()" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
    <div class="form-group">
        <label for="c-email" class="control-label col-xs-12 col-sm-2">{:__('Email')}:</label>
        <div class="col-xs-12 col-sm-4">
            <input id="c-email" data-rule="required" class="form-control" name="row[email]" type="text" value="">
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script>
    function code() {
        var password = document.getElementById('c-password');
        var passwordtext = document.getElementById('c-passwordtext');
        let chars = "ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        let maxPos = chars.length;
        var code = '';
        for (let i = 0; i < 6; i++) {
            code += chars.charAt(Math.floor(Math.random() * maxPos));
        }
        password.value = code;
        passwordtext.value = code;
    }
    code();

    //重置密码
    function resetpassword() {
        code();
    }
</script>